//
// Created by Soar Qin on 2017/8/18.
// Copyright (c) 2017 Soar Qin. All rights reserved.
//

#pragma once

#include "io_base.hh"

namespace core::async {

struct IoEventContext;

class IoEvent: public IoBase {
    DISABLE_CLASS_COPY(IoEvent);
public:
    explicit IoEvent(Loop &loop);
    ~IoEvent() override;

    inline IoEventContext *getContext() { return context_; }
    virtual bool close();

    virtual void onEvent(short events) {}

protected:
    bool startInternal(int fd, short op);
    void enableInternal(short op);

protected:
    IoEventContext *context_;
};

}
